//
//  TopicCommentCell.m
//  FbeeAPP
//
//  Created by dev-m on 2018/3/8.
//  Copyright © 2018年 mohao. All rights reserved.
//

#import "TopicCommentCell.h"
#import "BeePhotoImageView.h"
#import "TopicCommentObj.h"
#import "UrlLabel.h"

@interface TopicCommentCell()
{
    //头像
    BeePhotoImageView *photo;
    //昵称
    UILabel *nickName;
    //内容
    UrlLabel *content;
    //日期
    UILabel *dateInfo;
}

@end

@implementation TopicCommentCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self buildView];
        
    }
    
    return self;
}

-(void)buildView
{
    photo = [[BeePhotoImageView alloc] initWithFrame:CGRectMake(15, 30, 35, 35) imgByTitle:@"" photoStyle:BeePhotoCellStyle];
    [self addSubview:photo];
    
    nickName = [UILabel makeLabel:^(TTLabelExtend *make) {
        make.addBackGoundColor(FBEE_COLOR_PLACEHOLDER);
        make.addTextColor(FBEE_COLOR_THEME).addFont([UIFont systemFontOfSize:18.0f]);
        make.setFrame(CGRectMake(0, 0, 100, 23));
        make.left = photo.right + 10;
        make.top = photo.top - 1;
        [self addSubview:make];
    }];
    
    dateInfo = [UILabel makeLabel:^(TTLabelExtend *make) {
        make.addBackGoundColor(FBEE_COLOR_PLACEHOLDER);
        make.addTextColor(FBEE_COLOR_INFO).addFont([UIFont systemFontOfSize:12]);
        make.setFrame(CGRectMake(0, 0, 100, 13));
        make.left = nickName.left;
        make.top = content.bottom + 27;
        [self addSubview:make];
    }];
}

-(void)setDataObj:(TopicCommentObj *)obj
{
    [photo setTitle:obj.nickname];
    
    nickName.backgroundColor = [UIColor clearColor];
    nickName.text = obj.nickname;
    [nickName sizeToFit];
    nickName.height = 23;
    
    if (content) {
        [content removeFromSuperview];
    }
    content = obj.contentLab;
    content.left = photo.right + 10;
    content.top = nickName.bottom + 6;
    [self addSubview:content];
    
    dateInfo.bottom = obj.height;
    dateInfo.backgroundColor = [UIColor clearColor];
    dateInfo.text = obj.createTime;
    
    _dataObj = obj;
}



@end
